Unit BDijitDialogUnit;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, SysUtils, BDojoSessionUnit, BDijitContentPaneUnit;

Type

{ BDijitDialogClass }

 BDijitDialogClass = Class(BDijitContentPaneClass)
  Private
    bAutoFocus: Boolean;
    bDraggable: Boolean;
    bOpen: Boolean;
    bRefocus: Boolean;
    Procedure SetAutoFocus(aValue: Boolean);
    Procedure SetDraggable(aValue: Boolean);
    Procedure SetOpen(aValue: Boolean);
    Procedure SetRefocus(aValue: Boolean);
  Public
    //**  A Toggle to modify the default focus behavior of a Dialog, which is
    //** to focus on the first dialog element after opening the dialog. False
    //** will disable autofocusing. Default: true
    Property AutoFocus: Boolean Read bAutoFocus Write SetAutoFocus;
    //** Toggles the moveable aspect of the Dialog. If true, Dialog can be
    //** dragged by it's title. If false it will remain centered in the
    //** viewport.
    Property Draggable: Boolean Read bDraggable Write SetDraggable;
    //** True if Dialog is currently displayed on screen.
    Property Open: Boolean Read bOpen Write SetOpen;
    //** A Toggle to modify the default focus behavior of a Dialog, which is
    //** to re-focus the element which had focus before being opened. False
    //** will disable refocusing. Default: true
    Property Refocus: Boolean Read bRefocus Write SetRefocus;

    //** Hide the dialog
    Procedure Hide;
    //** Position the Dialog and the underlay
    Procedure Layout;
    //** Display the dialog
    Procedure Show;

    Constructor Build(Const aSession: BDojoSessionClass;
      Const aJSType: String = ''); Override;
End;

Implementation

{ BDijitDialogClass }

Procedure BDijitDialogClass.SetAutoFocus(aValue: Boolean);
Begin
  bAutoFocus := aValue;
  SetConfig('autoFocus', aValue);
End;

Procedure BDijitDialogClass.SetDraggable(aValue: Boolean);
Begin
  bDraggable := aValue;
  SetConfig('draggable', aValue);
End;

Procedure BDijitDialogClass.SetOpen(aValue: Boolean);
Begin
  bOpen := aValue;
  SetConfig('open', aValue);
End;

Procedure BDijitDialogClass.SetRefocus(aValue: Boolean);
Begin
  bRefocus := aValue;
  SetConfig('refocus', aValue);
End;

Procedure BDijitDialogClass.Hide;
Begin
  AddAjax('hide();');
End;

Procedure BDijitDialogClass.Layout;
Begin
  AddAjax('layout();');
End;

Procedure BDijitDialogClass.Show;
Begin
  AddAjax('show();');
End;

Constructor BDijitDialogClass.Build(Const aSession: BDojoSessionClass;
  Const aJSType: String);
Begin
  If aJSType = '' Then Inherited Build(aSession, 'dijit.Dialog')
  Else Inherited Build(aSession, aJSType);
End;

End.

